package com.snj.twelve;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class ListDirectoriesNIO {
    public static void main(String[] args) {
        String directoryPath = "D:\\0_莘纳吉\\慧能小电量\\1_报表替换文档备份";
        Path directory = Paths.get(directoryPath);

        try {
            if (Files.exists(directory) && Files.isDirectory(directory)) {
                Files.list(directory)
                        .filter(Files::isDirectory)
                        .forEach(path -> System.out.println(path.toAbsolutePath()));
            } else {
                System.out.println("specified path is invalid or not a directory.");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}